package com.xiaoxu.rental.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 *
 * @TableName sys_user
 */
@Data
@Accessors(chain = true)
@TableName("sys_user")
@ApiModel(value = "User对象", description = "")
public class User implements Serializable, UserDetails {
    /**
     * 用户id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 用户账户
     */
    private String username;

    /**
     * 用户密码
     */
    private String password;

    /**
     * 账户是否过期
     */
    private boolean isAccountNonExpired;

    /**
     * 账户是否被锁定
     */
    private boolean isAccountNonLocked;

    /**
     * 密码是否过期
     */
    private boolean isCredentialsNonExpired;

    /**
     * 账户是否可用
     */
    private boolean isEnabled;

    /**
     * 用户真实姓名
     */
    private String realname;

    /**
     * 用户昵称
     */
    private String nickname;

    /**
     * 所属部门id
     */
    private Integer deptId;

    /**
     * 所属部门名称
     */
    private String deptName;

    /**
     * 性别
     */
    private Integer gender;

    /**
     * 联系电话
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 是否管理员
     */
    private Integer isAdmin;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @TableField(fill =FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 是否删除
     */
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    //获取权限
    @TableField(exist = false)
    public Collection<? extends GrantedAuthority> authorities;
    //权限列表
    @TableField(exist = false)
    private List<Permission> permissionList;
}
